package de.devisnik.eidle.mine;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;

public final class MinesPreferences extends AbstractPreferenceInitializer {

	public static final int DEFAULT_FIELD_BOMBS = 100;
	public static final int DEFAULT_FIELD_HEIGHT = 20;
	public static final int DEFAULT_FIELD_WIDTH = 50;
	public static final String KEY_FIELD_BOMBS = "field_bombs";
	public static final String KEY_FIELD_WIDTH = "field_width";
	public static final String KEY_FIELD_HEIGHT = "field_height";
	public static final String PREFERENCES_PATH = MineActivator.PLUGIN_ID;
	public static final String KEY_ENABLED = "enabled";

	public MinesPreferences() {
	}

	public static int getWidth() {
		return getPreferences().getInt(KEY_FIELD_WIDTH);
	}

	public static int getHeight() {
		return getPreferences().getInt(KEY_FIELD_HEIGHT);
	}

	public static int getBombs() {
		return getPreferences().getInt(KEY_FIELD_BOMBS);
	}

	private static Preferences getPreferences() {
		return MineActivator.getDefault().getPluginPreferences();
	}

	public void initializeDefaultPreferences() {
		final Preferences preferences = getPreferences();
		preferences.setDefault(KEY_FIELD_BOMBS, DEFAULT_FIELD_BOMBS);
		preferences.setDefault(KEY_FIELD_WIDTH, DEFAULT_FIELD_WIDTH);
		preferences.setDefault(KEY_FIELD_HEIGHT, DEFAULT_FIELD_HEIGHT);
	}
}
